<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>nmrglue.varian &mdash; nmrglue v0.1 documentation</title>
    <link rel="stylesheet" href="../_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.1',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="nmrglue v0.1 documentation" href="../index.html" />
    <link rel="up" title="Reference Guide" href="index.html" />
    <link rel="next" title="nmrglue.proc_base" href="proc_base.html" />
    <link rel="prev" title="nmrglue.table" href="table.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="proc_base.html" title="nmrglue.proc_base"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="table.html" title="nmrglue.table"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">nmrglue v0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">Reference Guide</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="#">nmrglue.varian</a><ul>
<li><a class="reference external" href="#high-level-functions">High-Level Functions</a></li>
<li><a class="reference external" href="#low-level-functions">Low-Level Functions</a></li>
<li><a class="reference external" href="#low-level-classes">Low-Level Classes</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="table.html"
                                  title="previous chapter">nmrglue.table</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="proc_base.html"
                                  title="next chapter">nmrglue.proc_base</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/reference/varian.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-nmrglue.fileio.varian">
<h1>nmrglue.varian<a class="headerlink" href="#module-nmrglue.fileio.varian" title="Permalink to this headline">¶</a></h1>
<p>Functions for reading and writing Varian binary (fid) files and Varian 
parameter (procpar) files.</p>
<p>Both file formats are documented in:</p>
<ul class="simple">
<li>Varain MR News 2005-04-18 Importing Binary VnmrJ / VNMR FIDs into Third Party Software and VnmrJ / VNMR FID Data Format</li>
<li>VnmrJ User Programming - Chapter 5: Parameters and Data</li>
</ul>
<p>These are available (as of 04/2011) online from 
<a class="reference external" href="http://agilent.com">Agilent</a>.</p>
<p>This modules is imported as nmrglue.varian and can be called as such.</p>
<div class="section" id="high-level-functions">
<h2>High-Level Functions<a class="headerlink" href="#high-level-functions" title="Permalink to this headline">¶</a></h2>
<p>These are the functions most users will use from the varian module.</p>
<dl class="function">
<dt id="nmrglue.fileio.varian.read">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read</tt><big>(</big><em>dir='.'</em>, <em>fid_file='fid'</em>, <em>procpar_file='procpar'</em>, <em>read_blockhead=False</em>, <em>shape=None</em>, <em>torder=None</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read Varian files in a directory.</p>
<p>Parameters:</p>
<ul class="simple">
<li>dir               Directory holding Varian data.</li>
<li>fid_file          Name of fid file in directory.</li>
<li>procpar_file      Name of procpar file in directory.</li>
<li>read_blockhead    Set True to read blockheader(s). False otherwise.</li>
<li>shape             Shape of data, None tries to finds this automatically.</li>
<li>torder            Trace order (None for automatic). See read function.</li>
</ul>
<p>Returns: dic,data</p>
<p>Note in torder parameter:</p>
<p>torder is a parameter describing how the traces on disk should be 
re-organized to form the data matrix.  In many cases this can be determined
automatically by examining the order of phase parameters in the procpar
file, which is what is done if torder is set to None, but in some cases 
it must be explicitly provided.  Three common cases are:</p>
<p>Regular ordering (d3,d2,phase2,phase) which can be specificed by setting
torder to &#8216;regular&#8217; or &#8216;r&#8217;.</p>
<p>Opposite ordering (d3,d2,phase,phase2) which can be specified by setting
torder to &#8216;opposite&#8217; or &#8216;o&#8217;.</p>
<p>Flat ordering, the way data is on organized on disk, no reordering is 
performed. 1D and 2D file can be read in this manner.  Specify by setting 
torder to &#8216;flat&#8217; or &#8216;f&#8217;.</p>
<p>In addition a function which maps indirect dimension index tuples to/from
trace number as stored on disk can be provided.  For reading this function
should take 2 arguments (shape,index_tuple) and return an integer trace
number.  For writing this function should again take 2 arguments 
(shape,trace_number) and return the indirect dimension index tuple for the
given trace.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.read_lowmem">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read_lowmem</tt><big>(</big><em>dir='.'</em>, <em>fid_file='fid'</em>, <em>procpar_file='procpar'</em>, <em>read_blockhead=False</em>, <em>shape=None</em>, <em>torder=None</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read_lowmem" title="Permalink to this definition">¶</a></dt>
<dd><p>Read Varian files in a directory using minimal memory.</p>
<p>Parameters:</p>
<ul class="simple">
<li>dir               Directory holding Varian data.</li>
<li>fid_file          Name of fid file in directory.</li>
<li>procpar_file      Name of procpar file in directory.</li>
<li>read_blockhead    Set True to head blockheader(s). False otherwise.</li>
<li>shape             Shape of data, None tries to finds this automatically.</li>
<li>torder            Trace order (None for automatic). See read function.</li>
</ul>
<p>Returns: dic,data</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.write">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">write</tt><big>(</big><em>dir</em>, <em>dic</em>, <em>data</em>, <em>fid_file='fid'</em>, <em>procpar_file='procpar'</em>, <em>torder=None</em>, <em>repack=False</em>, <em>overwrite=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write Varian files to a directory.</p>
<p>Parameters:</p>
<ul class="simple">
<li>dir               Directory to write to.</li>
<li>dic               Python dictionary of file parameters.</li>
<li>data              Array of spectral data to write.</li>
<li>fid_file          Name of fid file to write to.</li>
<li>procpar_file      Name of procpar file to write to.</li>
<li>torder            Trace order (None for automatic). See read function.</li>
<li>repack            True/False to repack file and block headers.</li>
<li>overwrite         True/False to overwrite existing file.</li>
</ul>
<p>No return value.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.write_lowmem">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">write_lowmem</tt><big>(</big><em>dir</em>, <em>dic</em>, <em>data</em>, <em>fid_file='fid'</em>, <em>procpar_file='procpar'</em>, <em>torder=None</em>, <em>repack=False</em>, <em>overwrite=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.write_lowmem" title="Permalink to this definition">¶</a></dt>
<dd><p>Write Varian files to a directory using minimal memory</p>
<p>Parameters:</p>
<ul class="simple">
<li>dir               Directory to write to.</li>
<li>dic               Python dictionary of file parameters.</li>
<li>data              Array of spectral data to write.</li>
<li>fid_file          Name of fid file to write to.</li>
<li>procpar_file      Name of procpar file to write to.</li>
<li>torder            Trace order (None for automatic). See read function.</li>
<li>repack            True/False to repack file and block headers.</li>
<li>overwrite         True/False to overwrite existing file.</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.read_fid">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read_fid</tt><big>(</big><em>filename</em>, <em>shape=None</em>, <em>torder='flat'</em>, <em>read_blockhead=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read_fid" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a Varian binary (fid) file.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">filename          Varian binary file (fid) to read.</p>
</li>
<li><p class="first">shape             Shape of the Varian fid file.</p>
</li>
<li><p class="first">torder            Trace order. See read function.</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the Varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data</p>
<p>If shape is not provided file is read as a 2D.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.read_fid_lowmem">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read_fid_lowmem</tt><big>(</big><em>filename</em>, <em>shape=None</em>, <em>torder='flat'</em>, <em>read_blockhead=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read_fid_lowmem" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a Varian binary (fid) file.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">filename          Varian binary file (fid) to read.</p>
</li>
<li><p class="first">shape             Shape of the Varian fid file.</p>
</li>
<li><p class="first">torder            Trace order. See read function.</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the Varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data</p>
<p>If shape is not provided file is read as a 2D.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.read_fid_ntraces">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read_fid_ntraces</tt><big>(</big><em>filename</em>, <em>shape=None</em>, <em>torder='flat'</em>, <em>read_blockhead=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read_fid_ntraces" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a Varian binary (fid) file possibility having multiple traces per 
block.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">filename          Varian binary file (fid) to read.</p>
</li>
<li><p class="first">shape             Shape of the Varian fid file.</p>
</li>
<li><p class="first">torder            Trace order. See read function.</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data</p>
<p>If shape is not provided file is read as a 2D.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.write_fid">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">write_fid</tt><big>(</big><em>filename</em>, <em>dic</em>, <em>data</em>, <em>torder='flat'</em>, <em>repack=False</em>, <em>overwrite=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.write_fid" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a Varian binary (fid) file</p>
<p>Parameters:</p>
<ul class="simple">
<li>filename  Name of fid file to write to.</li>
<li>dic       Python dictionary of file parameters.</li>
<li>data      Array of spectral data to write.</li>
<li>torder    Trace order (None for automatic). See read function.</li>
<li>repack    True/False to repack file and block headers.</li>
<li>overwrite True/False to overwrite existing file.</li>
</ul>
<p>No return value.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.write_fid_lowmem">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">write_fid_lowmem</tt><big>(</big><em>filename</em>, <em>dic</em>, <em>data</em>, <em>torder='f'</em>, <em>repack=False</em>, <em>overwrite=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.write_fid_lowmem" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a Varian binary (fid) file trace by trace (low memory)</p>
<p>Parameters:</p>
<ul class="simple">
<li>filename  Name of fid file to write to.</li>
<li>dic       Python dictionary of file parameters.</li>
<li>data      Array of spectral data to write.</li>
<li>torder    Trace order (None for automatic). See read function.</li>
<li>repack    True/False to repack file and block headers.</li>
<li>overwrite True/False to overwrite existing file.</li>
</ul>
<p>No return value.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.read_procpar">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">read_procpar</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.read_procpar" title="Permalink to this definition">¶</a></dt>
<dd>Read a procpar file returning a python dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.write_procpar">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">write_procpar</tt><big>(</big><em>filename</em>, <em>dic</em>, <em>overwrite=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.write_procpar" title="Permalink to this definition">¶</a></dt>
<dd>Write a varian procpar file from python dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.guess_udic">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">guess_udic</tt><big>(</big><em>dic</em>, <em>data</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.guess_udic" title="Permalink to this definition">¶</a></dt>
<dd>Guess parameter of universal dictionary from dic,data</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.create_dic">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">create_dic</tt><big>(</big><em>udic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.create_dic" title="Permalink to this definition">¶</a></dt>
<dd>Create a Varian dictionary from a universal dictionary</dd></dl>

</div>
<div class="section" id="low-level-functions">
<h2>Low-Level Functions<a class="headerlink" href="#low-level-functions" title="Permalink to this headline">¶</a></h2>
<p>These functions are typically not used directly by users.  They are called by
high level functions.  Developers and user who want fine control over varian
files will be interested in these functions.</p>
<dl class="function">
<dt id="nmrglue.fileio.varian.create_data">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">create_data</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.create_data" title="Permalink to this definition">¶</a></dt>
<dd>Create a Varian data array (recast into complex64 array)</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.create_pdic_param">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">create_pdic_param</tt><big>(</big><em>name</em>, <em>values</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.create_pdic_param" title="Permalink to this definition">¶</a></dt>
<dd>Create a fake procpar dictionary element of name name, with values</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.find_torder">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">find_torder</tt><big>(</big><em>dic</em>, <em>shape</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.find_torder" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the torder from the procpar dictionary</p>
<p>Parameters:</p>
<ul class="simple">
<li>dic   procpar dictionary.</li>
<li>shape Shape of</li>
</ul>
<p>Returns: torder (file trace ordering string shortcut)</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.torder2i2t">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">torder2i2t</tt><big>(</big><em>torder</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.torder2i2t" title="Permalink to this definition">¶</a></dt>
<dd>Convert torder to index2trace function</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.torder2t2i">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">torder2t2i</tt><big>(</big><em>torder</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.torder2t2i" title="Permalink to this definition">¶</a></dt>
<dd>Convert torder to trace2index functions</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.reorder_data">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">reorder_data</tt><big>(</big><em>data</em>, <em>shape</em>, <em>torder</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.reorder_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Reorder data (raw from disk) packed with torder and shape</p>
<p>Parameters:</p>
<ul class="simple">
<li>data  Data (2D) array, ordered as on disk.</li>
<li>shape True shape of data</li>
<li>toder Trace order. See read function.</li>
</ul>
<p>Returns: data (data with shape shape and ordered correctly)</p>
<p>No error checking is done to see if data and shape contain the same
number of values.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.order_data">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">order_data</tt><big>(</big><em>data</em>, <em>torder</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.order_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Order data for writing to disk</p>
<p>Parameters:</p>
<ul class="simple">
<li>data      Data array</li>
<li>torder    Trace order. See read function.</li>
</ul>
<p>Returns: data (2D array ordered for writing to disk)</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_nblocks">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_nblocks</tt><big>(</big><em>f</em>, <em>nblocks</em>, <em>pts</em>, <em>nbheaders</em>, <em>dt</em>, <em>read_blockhead</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_nblocks" title="Permalink to this definition">¶</a></dt>
<dd><p>Read n blocks from a Varian binary file.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">f                 File object of varian binaruy file</p>
</li>
<li><p class="first">nblocks           Number of blocks to read</p>
</li>
<li><p class="first">pts               Number of points per trace</p>
</li>
<li><p class="first">nbheaders         Number of block headers in each block</p>
</li>
<li><p class="first">dt                Data type of data in binary file (real)</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    True to read the Varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data if read_blockhead is True, data if False</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_block">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_block</tt><big>(</big><em>f</em>, <em>pts</em>, <em>nbheaders</em>, <em>dt</em>, <em>read_blockhead=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_block" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a block from Varian binary file.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">f                 File object of varian binaruy file.</p>
</li>
<li><p class="first">pts               Number of points per trace.</p>
</li>
<li><p class="first">nbheaders         Number of block headers in each block</p>
</li>
<li><p class="first">dt                Data type of data in binary file (real).</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data if read_blockhead is True, data if False</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_nblocks_ntraces">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_nblocks_ntraces</tt><big>(</big><em>f</em>, <em>nblocks</em>, <em>ntraces</em>, <em>pts</em>, <em>nbheaders</em>, <em>dt</em>, <em>read_blockhead</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_nblocks_ntraces" title="Permalink to this definition">¶</a></dt>
<dd><p>Read n blocks from a Varian binary file which may have multiple traces
per block.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">f                 File object of Varian binary file to read from.</p>
</li>
<li><p class="first">nblocks           Number of blocks to read.</p>
</li>
<li><p class="first">ntraces           Number of traces per block.</p>
</li>
<li><p class="first">pts               Number of points per trace.</p>
</li>
<li><p class="first">nbheaders         Number of block headers in each block.</p>
</li>
<li><p class="first">dt                Data type of data in binary file (real).</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data if read_blockhead is True, data if False</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_block_ntraces">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_block_ntraces</tt><big>(</big><em>f</em>, <em>ntraces</em>, <em>pts</em>, <em>nbheaders</em>, <em>dt</em>, <em>read_blockhead=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_block_ntraces" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a block from Varian binary file which may have multiple traces per 
block.</p>
<p>Parameters:</p>
<ul>
<li><p class="first">f                 File object of Varian binary file to read from.</p>
</li>
<li><p class="first">ntraces           Number of traces per block.</p>
</li>
<li><p class="first">pts               Number of points per trace.</p>
</li>
<li><p class="first">nbheaders         Number of block headers in each block.</p>
</li>
<li><p class="first">dt                Data type of data in binary file (real).</p>
</li>
<li><dl class="first docutils">
<dt>read_blockhead    Set to True to read the varian blockheaders(s) into</dt>
<dd><p class="first last">the returned dictionary. False ignores them.</p>
</dd>
</dl>
</li>
</ul>
<p>Returns: dic,data if read_blockhead is True, data if False.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_trace">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_trace</tt><big>(</big><em>f</em>, <em>pts</em>, <em>dt</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_trace" title="Permalink to this definition">¶</a></dt>
<dd><p>Read trace of pts points of dtype dt from Varian binary file</p>
<p>Does not correct Endiness as dt should handle this</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_fileheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_fileheader</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_fileheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Unpack file header parameters into list.</p>
<p>Reads the 32-byte file header from file and unpacks into a list.  Endiness
is corrected as needed.</p>
<p>Returned list contents:</p>
<table border="1" class="docutils">
<colgroup>
<col width="2%" />
<col width="19%" />
<col width="79%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">N</th>
<th class="head">Variable</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>0</td>
<td>nblocks</td>
<td>data blocks in file</td>
</tr>
<tr><td>1</td>
<td>ntraces</td>
<td>traces per block</td>
</tr>
<tr><td>2</td>
<td>np</td>
<td>elements per trace</td>
</tr>
<tr><td>3</td>
<td>ebytes</td>
<td>bytes per element</td>
</tr>
<tr><td>4</td>
<td>tbytes</td>
<td>bytes per trace</td>
</tr>
<tr><td>5</td>
<td>bbytes</td>
<td>bytes per block</td>
</tr>
<tr><td>6</td>
<td>vers_id</td>
<td>software version, file_id status bits</td>
</tr>
<tr><td>7</td>
<td>status</td>
<td>status of whole file</td>
</tr>
<tr><td>8</td>
<td>nbheaders</td>
<td>number of block headers per block (1)</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_blockheader</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_blockheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Unpack block header parameters into a list.</p>
<p>Reads the 28-byte block header from f and unpacks into a list.  Endiness
is corrected as needed.</p>
<p>Returned list contents:</p>
<table border="1" class="docutils">
<colgroup>
<col width="3%" />
<col width="24%" />
<col width="73%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">N</th>
<th class="head">Variable</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>0</td>
<td>scale</td>
<td>scaling factor</td>
</tr>
<tr><td>1</td>
<td>status</td>
<td>status of data in block</td>
</tr>
<tr><td>2</td>
<td>index</td>
<td>block index</td>
</tr>
<tr><td>3</td>
<td>mode</td>
<td>block mode</td>
</tr>
<tr><td>4</td>
<td>ctcount</td>
<td>ct value of FID</td>
</tr>
<tr><td>5</td>
<td>lpval</td>
<td>left phase</td>
</tr>
<tr><td>6</td>
<td>rpval</td>
<td>right phase</td>
</tr>
<tr><td>7</td>
<td>lvl</td>
<td>level drift correction</td>
</tr>
<tr><td>8</td>
<td>tlt</td>
<td>tilt drift correction</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.skip_blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">skip_blockheader</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.skip_blockheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Read a block header but do not unpack</p>
<p>This is a replacement for get_blockheader.  It skips f ahead 28 bytes.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_hyperheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_hyperheader</tt><big>(</big><em>file</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_hyperheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Unpack hypercomplex header parameters to a list.</p>
<p>Reads the 28-bytes block header from file and unpacks into a list. Endiness
is corrected as needed.</p>
<p>Returned list contents:</p>
<table border="1" class="docutils">
<colgroup>
<col width="4%" />
<col width="32%" />
<col width="64%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">N</th>
<th class="head">Variable</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>0</td>
<td>s_spare1</td>
<td>Not Used</td>
</tr>
<tr><td>1</td>
<td>status</td>
<td>status of block</td>
</tr>
<tr><td>2</td>
<td>s_spare2</td>
<td>Not Used</td>
</tr>
<tr><td>3</td>
<td>s_spart3</td>
<td>Not Used</td>
</tr>
<tr><td>4</td>
<td>l_spare1</td>
<td>Not Used</td>
</tr>
<tr><td>5</td>
<td>lpval1</td>
<td>2D left phase</td>
</tr>
<tr><td>6</td>
<td>rpval1</td>
<td>2D right phase</td>
</tr>
<tr><td>7</td>
<td>f_spare1</td>
<td>Not Used</td>
</tr>
<tr><td>8</td>
<td>f_spare2</td>
<td>Not Used</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.put_block">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">put_block</tt><big>(</big><em>f</em>, <em>trace</em>, <em>nbheaders</em>, <em>bh</em>, <em>hh=False</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.put_block" title="Permalink to this definition">¶</a></dt>
<dd><p>Put blockheader(s) and trace to file</p>
<p>Parameters:</p>
<ul class="simple">
<li>f         File object to write to.</li>
<li>trace     Trace to write to block.</li>
<li>nbheaders Number of block headers.</li>
<li>bh        Blockheader list.</li>
<li>hh        Hyperheader list (if required).</li>
</ul>
<p>when nbheaders &gt; 2, additional headers are written as all zeros.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.put_trace">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">put_trace</tt><big>(</big><em>f</em>, <em>trace</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.put_trace" title="Permalink to this definition">¶</a></dt>
<dd>Write trace to file f.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.put_fileheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">put_fileheader</tt><big>(</big><em>f</em>, <em>fh</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.put_fileheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Write fileheader list to file (32-bytes written)</p>
<p>Parameters:</p>
<ul class="simple">
<li>f     file object</li>
<li>fh    fileheader list (length 9)</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.put_blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">put_blockheader</tt><big>(</big><em>f</em>, <em>bh</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.put_blockheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Write blockheader list to file (28-bytes written)</p>
<p>Parameters:</p>
<ul class="simple">
<li>f     file object</li>
<li>bh    blockheaders list, length 9</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.put_hyperheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">put_hyperheader</tt><big>(</big><em>f</em>, <em>hh</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.put_hyperheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Write hyperheader list to file (28-bytes written)</p>
<p>Parameters:</p>
<ul class="simple">
<li>f     file object</li>
<li>hh    hyperheader list, length 9</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.hyperheader2dic">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">hyperheader2dic</tt><big>(</big><em>head</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.hyperheader2dic" title="Permalink to this definition">¶</a></dt>
<dd>Convert a hypercomplex block header into a python dictionary.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.repack_hyperheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">repack_hyperheader</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.repack_hyperheader" title="Permalink to this definition">¶</a></dt>
<dd>Repack hyperheader dictionary bit flag parameters into status.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.dic2hyperheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">dic2hyperheader</tt><big>(</big><em>head</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.dic2hyperheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a python dictionary into a hypercomplex block header list.</p>
<p>Does not repack status from bit flags.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.make_blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">make_blockheader</tt><big>(</big><em>filedic=False</em>, <em>index=1</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.make_blockheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a generic blockheader dictionary with a given block index.</p>
<p>filedic can be provided for status flags, if not provided creates 
header for float32 data</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.blockheader2dic">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">blockheader2dic</tt><big>(</big><em>head</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.blockheader2dic" title="Permalink to this definition">¶</a></dt>
<dd>Convert a block header list into a python dictionary.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.repack_blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">repack_blockheader</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.repack_blockheader" title="Permalink to this definition">¶</a></dt>
<dd>Repack blockheader dic bit flag parameters into status and mode.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.dic2blockheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">dic2blockheader</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.dic2blockheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a python dictionary into block header list.</p>
<p>Does not repack status and mode from bit flags.</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.fileheader2dic">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">fileheader2dic</tt><big>(</big><em>head</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.fileheader2dic" title="Permalink to this definition">¶</a></dt>
<dd>Convert fileheader list into a python dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.repack_fileheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">repack_fileheader</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.repack_fileheader" title="Permalink to this definition">¶</a></dt>
<dd>Repack blockheader dic bit flag parameters into status and mode.</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.dic2fileheader">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">dic2fileheader</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.dic2fileheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a python dictionary into a fileheader list</p>
<p>Does not repack status from bit flags</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.find_shape">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">find_shape</tt><big>(</big><em>pdic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.find_shape" title="Permalink to this definition">¶</a></dt>
<dd>Determine the shape of a varian file from the procpar dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.find_cdtype">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">find_cdtype</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.find_cdtype" title="Permalink to this definition">¶</a></dt>
<dd>Find the complex dtype from a dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.find_dtype">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">find_dtype</tt><big>(</big><em>dic</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.find_dtype" title="Permalink to this definition">¶</a></dt>
<dd>Find the dtype from a dictionary</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.uninterleave_data">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">uninterleave_data</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.uninterleave_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Unpack interleaved real,imag data</p>
<table border="1" class="docutils">
<colgroup>
<col width="45%" />
<col width="55%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">data dtype</th>
<th class="head">Return dtype</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>int16</td>
<td>&#8216;complex64&#8217;</td>
</tr>
<tr><td>float32</td>
<td>&#8216;complex64&#8217;</td>
</tr>
<tr><td>int32</td>
<td>&#8216;complex128&#8217;</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.interleave_data">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">interleave_data</tt><big>(</big><em>data_in</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.interleave_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Interleave real, imag data</p>
<p>Does not check if resulting dtype is a valid varian dtype</p>
</dd></dl>

<dl class="function">
<dt id="nmrglue.fileio.varian.get_parameter">
<tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">get_parameter</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.get_parameter" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads a procpar parameter from a file object</p>
<p>Returns a dictionary with the attributes of the parameter</p>
</dd></dl>

</div>
<div class="section" id="low-level-classes">
<h2>Low-Level Classes<a class="headerlink" href="#low-level-classes" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="nmrglue.fileio.varian.fid_nd">
<em class="property">class </em><tt class="descclassname">nmrglue.fileio.varian.</tt><tt class="descname">fid_nd</tt><big>(</big><em>filename</em>, <em>i2t_func</em>, <em>fshape=None</em>, <em>order=None</em><big>)</big><a class="headerlink" href="#nmrglue.fileio.varian.fid_nd" title="Permalink to this definition">¶</a></dt>
<dd><p>Emulate a numpy.ndarray objects without loading data into memory for low
memory reading of Varian fid files (one trace per block)</p>
<ul class="simple">
<li>slicing operations return ndarray objects.</li>
<li>can iterate over with expected results.</li>
<li>transpose and swapaxes methods create a new objects with correct axes
ordering.</li>
<li>has ndim, shape, and dtype attributes.</li>
</ul>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="proc_base.html" title="nmrglue.proc_base"
             >next</a> |</li>
        <li class="right" >
          <a href="table.html" title="nmrglue.table"
             >previous</a> |</li>
        <li><a href="../index.html">nmrglue v0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" >Reference Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Jonathan J. Helmus.
      Last updated on Apr 04, 2011.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
    </div>
  </body>
</html>